const mulitPage = require('./mulit-page');
let mulitRoot = {};
mulitPage.getEntries('src/pages/**/*.js').forEach(item => {
  mulitRoot[item.title] = item;
})
const entry = Object.assign({}, mulitRoot);

module.exports = {
  publicPath: "./",
  configureWebpack: {
    output: {
      filename: 'js/[name].js',
      chunkFilename: 'js/chunk/[name]/[name].js'
    },
    resolve: {
      alias: {
        'assets': '@/assets',
        'components': '@/components',
        'views': '@/views',
        'common': '@/common',
        'base': '@/base',
        'pages': '@/pages'
      }
    }
  },
  pages: {
    index: {
      entry: "src/main.js",
      template: "public/index.html",
      filename: "index.html",
      title: "index"
    },
    ...entry
    // login: {
    //   entry: "src/pages/login/login.js",
    //   template: "src/pages/login/login.html",
    //   filename: "login.html",
    //   title: "login"
    // }
  },
  devServer: {
    proxy: {
      '/rng': {  
        target: 'http://45.105.124.130:8081', 
        ws: true,//如果要代理 websockets，配置这个参数        
        secure: false,// 如果是https接口，需要配置这个参数  
        changeOrigin: true,  //是否跨域
        pathRewrite: {  // 将接口重写 如果设置为空 就是 http://XX.XX.XX.XX:8083/login 如果为本身 http://XX.XX.XX.XX:8083/rng/login
          '^/rng': '/rng'
        }
      }
    }
  }
}